LONG Dlock( WORD mode, WORD drv );
If bit 0 of mode is 1, the drive is locked; if it is 0 then the drive is unlocked and may be used again by other programs. If a process terminates while holding a lock on a drive, that drive is automatically unlocked.
Bit 1 of mode indicates what return values are desired. If this bit is 1, and if the drive is locked by a user process different from the caller, or if some process has files open on the drive, then that process' id will be returned (see below). This may be used to report a more useful error message to the user (by telling him or her which process is using the drive in question when a lock operation fails).
All other bits of mode are reserved and must be set to 0.
A lock operation followed immediately by an unlock is very similar to a media change, except that the lock operation will fail if there are open files that refer to the indicated drive.
EDRIVE if drv is not a valid BIOS device number
For a lock operation, the following error codes may be returned:
A positive process id if bit 1 of mode is set, and the drive is already locked or in use by another user process.
EACCDN if bit 1 of mode is clear and either open files exist on the drive or another process is searching a directory on the drive, or if bit 1 of mode is set and the drive is in use by the operating system.
ELOCKED if bit 1 of mode is clear and another process has locked the drive, or if bit 1 of mode is set and the operating system has locked the drive.
For an unlock operation the following error codes may be returned:
ENSLOCK if mode is 0 and the drive was not locked by this process